package com.imddysc.dwz.utils;

public enum ResultCode {

	SUCCESS(0, "成功"),
	FAILURE(1, "失败"),
	EXECEPTION(2,"异常");
	
	private Integer code;
	
	private String message;

	
	ResultCode(Integer code, String message) {
		this.code = code;
		this.message = message;
	}
	
	public Integer code() {
		return this.code;
	}
	
	public String message() {
		return this.message;
	}
	
	public static Integer getCode(String name) {
		for (ResultCode item : ResultCode.values() ) {
			if (item.name().equals(name)) {
				return item.code;
			}
		}
		return null;
	}
	
	public static String getMessage(String name) {
		for (ResultCode item : ResultCode.values() ) {
			if (item.name().equals(name)) {
				return item.message;
			}
		}
		return name;
	}
	
	@Override
	public String toString() {
		return this.name();
	}
}
